package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.oilPointPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:oilPointMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/6/23 20:59
 * @Version 1.0
 */
@Mapper
public interface oilPointMapp {
    //插入一条完整的记录
    @DS("baodingRussia")
    @Insert("INSERT INTO oillpoint_main " +
            "(workshop, lineName, equipmentName, op, " +
            "oilPointName, oilPoint, oilPointAnnex, oilName, " +
            "oilCycle, oilQuantity, LastDate, oilBook, " +
            "bookAnnex, oilPerson, oilRecord, deleteSign, " +
            "establishTime, UpdateTime)" +
            " VALUES " +
            "(#{workshop},#{lineName},#{equipmentName},#{op}," +
            "#{oilPointName},#{oilPoint},#{oilPointAnnex},#{oilName}," +
            "#{oilCycle},#{oilQuantity},#{LastDate},#{oilBook}," +
            "#{bookAnnex},#{oilPerson},#{oilRecord},#{deleteSign}," +
            "#{establishTime},#{UpdateTime})")
    void insertOne(oilPointPojo oilPoint);
    //查询所有的列表信息
    @DS("baodingRussia")
    @Select("select * from oillpoint_main where deleteSign=1")
    List<oilPointPojo> selectAllList();
    //修改某一行的数据
    @DS("baodingRussia")
    @Update("UPDATE oillpoint_main set " +
            "workshop=#{workshop}," +
            "lineName=#{lineName}," +
            "op=#{op}," +
            "equipmentName=#{equipmentName}," +
            "oilPointName=#{oilPointName}," +
            "oilPerson=#{oilPerson}," +
            "oilName=#{oilName}," +
            "oilCycle=#{oilCycle}," +
            "oilQuantity=#{oilQuantity}," +
            "deleteSign=#{deleteSign} where id=#{id}")
    void ilPointUpListOne(oilPointPojo oilPoint);
//根据id，修改某一个字段的值（使用修改字符串的)
@DS("baodingRussia")
    @Update("update oillpoint_main set ${fieldName}=#{fieldValue} ,UpdateTime=#{dateTime} where id=#{id}")
    void iolPointOneField(Integer id, String fieldName, String fieldValue, LocalDateTime dateTime);
}
